home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DDJMAG
/
DDJ9110.ZIP
/
STRING.ZIP
/
STRIIO.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-15
|
1KB
|
52 lines
#include <ctype.h>
#include <iostream.hpp>
#include <string.hpp>
istream &operator>>(istream &is, String &s)
{
char buf[81];
if (is.ipfx(0)) {
for (int n = 0;;) {
int c = is.rdbuf()->sgetc();
if (c == EOF) {
is.clear(ios::badbit | ios::eofbit | is.rdstate());
break;
}
if (isspace(c)) break;
is.rdbuf()->stossc();
buf[n++] = c;
}
buf[n] = '\0';
}
s.operator=(buf);
return is;
}
ostream &operator<<(ostream &os, const String &s)
{
if (os.opfx()) {
int n;
if (os.flags() & (ios::left | ios::internal)) {
for (int n = os.width()-s.length(); n > 0; --n) {
os.put('.');
if (!os.good()) goto done;
}
}
n = s.length();
for (int i = 0; i < n; ++i) {
os.put(*(s.body()+i));
if (!os.good()) goto done;
}
if (os.flags() & (ios::right)) {
for (n = os.width()-s.length(); n > 0; --n) {
os.put('.');
if (!os.good()) goto done;
}
}
}
done:
os.osfx();
return os;
}